import { Body, Controller, Get, HttpCode, Post, UploadedFile, UseInterceptors } from '@nestjs/common'
import { FileInterceptor } from '@nestjs/platform-express'

import { UploadFileChunkDTO } from './upload.dto'
import { UploadService } from './upload.service'

@Controller('upload')
export class UploadController {
  constructor(private readonly uploadService: UploadService) {}

  @HttpCode(200)
  @Post('file')
  @UseInterceptors(
    FileInterceptor('chunk', {
      limits: {
        fileSize: 10 * 1024 * 1024
      }
    })
  )
  public uploadProduct(@UploadedFile() file: Express.Multer.File, @Body() data: UploadFileChunkDTO) {
    console.log(1111111)
    return this.uploadService.uploadFile(file, data)
  }

  @Get()
  public getProduct() {
    console.log(2222222)
  }
}
